home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com(Pete)
- Newsgroups: comp.lang.c++
- Subject: iostream-stdio speed - again
- Date: 15 Jan 1996 23:09:33 GMT
- Organization: Kalevi, Inc
- Message-ID: <4demrd$mkr@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe9.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- Remember the recent thread with similar subject? Some of us,
- including I, stated that the 4:1 ratio iostream vs. stdio
- was excessive -- possibly due to the original poster using
- an old compiler: BC 2.0, I think.
-
- I take it all back! I just had a need to process a 56mb text
- file by reading it in a line at a time, making an insignificant
- mod, and writing the line to another file. I decided to try a
- stdio version as well as an iostream one. I used what I consider
- to be equivalent code. Compiler was MSVC++ 4.0 running in Windows
- NT 3.51. No time to test with other compilers right now.
-
- The results:
-
- LIBRARY TIME
- stdio 3:44
- iostream 12:17
-
- Significant details:
-
- iostream:
- Loop
- is.getline(buf, xxx)
- minor mod
- os << buf << '\n';
- // Note: dropped endl in case it caused extra
- // inefficiency due to flushing.
-
- stdio:
- Loop
- fgets(buf, xxx, infile);
- minor mod
- fputs(buf, outfile);
-
- Because this was a one-time mod, I didn't try to write more
- efficient routine by using block reads or the like. I also realize
- that some may disagree on the 'equivalency' of the two methods.
-
-
- --
-
- Pete
-
-
-
-
-
-